package com.zh.test.excel;

import org.apache.poi.ss.usermodel.*;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;

/**
 * @Author zh
 * @Description 测试poi解析excel
 * @Date 2020/5/27 
 * @Param 
 * @return 
 **/
public class ReadExcel {
    public static void main(String[] args) throws IOException {
        InputStream inp = null;
        try {
            inp = new FileInputStream("F:\\wenxin\\WeChat Files\\EmaryZH\\FileStorage\\File\\2020-05\\test.xlsx");
            Workbook wb = WorkbookFactory.create(inp);
            Sheet sheet = wb.getSheetAt(3);
            Iterator<Row> rowIterator = sheet.rowIterator();
            Row r = sheet.getRow(5);
            for(int i = 0;i<r.getLastCellNum();i++){
                Cell c = r.getCell(i);
                System.out.println(c.getCellType());
            }


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inp != null) {
                inp.close();
            }
        }
    }

}
